package xyz.weblade.lynchmybatis;

/**
 * @author lynch
 * @since 2024/12/3 v1.0
 * 玩玩
 */
public class Main {
    public static void main(String[] args) {
        Integer a = 1;
        Integer b = 2;
        Integer c = 3;
        Integer d = 3;
        Integer e = 321;
        Integer f = 321;
        Integer aa =100;
        Integer bb = 221;
        Long g = 3L;
        //比较地址，低于-128~127的都会使用缓存的Integer对象
        System.out.println(c == d);
        System.out.println(e == f);
        //+法导致拆箱，这里是比较数值
        System.out.println(e == (f + 0));
        System.out.println(c == (a + b));
        System.out.println(c.equals(a + b));
        System.out.println(g == (a + b));
        System.out.println(f == (aa+bb));
        //这里a+b确实是值，但是因为Long对象比较的时候，如果a+b是int不是Long，就会直接返回false
        System.out.println(g.equals(a + b));
        /**
         *Integer a = Integer.valueOf(1);
         *         Integer b = Integer.valueOf(2);
         *         Integer c = Integer.valueOf(3);
         *         Integer d = Integer.valueOf(3);
         *         Integer e = Integer.valueOf(321);
         *         Integer f = Integer.valueOf(321);
         *         Integer aa = Integer.valueOf(100);
         *         Integer bb = Integer.valueOf(221);
         *         Long g = Long.valueOf(3L);
         *         System.out.println(c == d);
         *         System.out.println(e == f);
         *         System.out.println(e.intValue() == f.intValue() + 0);
         *         System.out.println(c.intValue() == a.intValue() + b.intValue());
         *         System.out.println(c.equals(Integer.valueOf(a.intValue() + b.intValue())));
         *         System.out.println(g.longValue() == (long)(a.intValue() + b.intValue()));
         *         System.out.println(f.intValue() == aa.intValue() + bb.intValue());
         *         System.out.println(g.equals(Integer.valueOf(a.intValue() + b.intValue())));
         */
    }

}
